package com.innova_t.android.mario;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ListView;

import com.innova_t.android.mario.items.ContactDTO;
import com.innova_t.android.mario.items.ContactDetailActivity;

public class MobilistestActivity extends ListActivity {
    
	private static final String TAG = "Listoh";
	private static final int ACTIVITY_EDIT = 0;
	private ItemsDbAdapter mDbHelper;

	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        Log.i(TAG, "before starting the db"  );
        
        Log.i(TAG, "client object created");
        
//        String status = clientRes.getStatus("ok");
        
//        Log.i(TAG, "status: " + status );
        
        List<ContactDTO> lista = new ArrayList();
        
        if( lista == null ){
        	Log.i(TAG, "there are no lists available");
        	return;
        }
        
        setListAdapter( new ContactAdapter(lista) );
        
        
    }
    
    
    @Override
	protected void onListItemClick(ListView parent, View v, int position, long id) {
//		super.onListItemClick(parent, v, position, id);
		
		// get adpter
    	ContactAdapter adptr = (ContactAdapter)  parent.getAdapter();
		
    	ContactDTO listoLista = (ContactDTO) adptr.getItem(position);
		//contact.msgCount++;
		
		// pasamos a items y guardamos a bbdd
		adptr.notifyDataSetInvalidated();
		
		
        Log.i(TAG, "all items done"  );
        
//        Intent i = new Intent(this, ContactDetailActivity.class);
//        i.putExtra(ItemsDbAdapter.KEY_ROWID, listoLista.getId() );
//        i.putExtra(ContactDetailActivity.REST_URL, urlForItems );
//        startActivityForResult(i, ACTIVITY_EDIT);
        
	}
}